/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Logger;

import javafx.scene.CustomNode;
import javafx.scene.Node;
import javafx.scene.Group;
import javafx.scene.control.Button;
import parismetro.Main;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.control.Hyperlink;
import javafx.stage.AppletStageExtension;

/**
 * @author Hadrien
 */

public class TaskScreen extends CustomNode {
    def f30 = Font { size: 26 };
    def f48 = Font { size: 48 };
    def titre = Text {
                font: f48
                layoutX: 200
                layoutY: 60
                content: "Liste des tâches à effectuer.\nLa prochaine tâche est en rouge."
                textAlignment: TextAlignment.CENTER
            };
    def task = VBox{
                layoutX: 100
                layoutY: 160
                spacing: 30;
                content: [
                    for (t in Main.logger.reachedTask) {
                        Text {
                            font: f30
                            content: t.taskName
                            wrappingWidth: 800
                            fill: Color.GRAY;
                        };
                    }
                    for (i in [0..Main.logger.todoTask.size()-1]) {
                        Text {
                            font: f30
                            content: Main.logger.todoTask.get(i).taskName
                            wrappingWidth: 700
                            fill: bind if (i==0) Color.RED else Color.BLACK
                        };
                    }
                    ]
    }
    public function notifyTask(){
        task.content = [
                    for (t in Main.logger.reachedTask) {
                        Text {
                            font: f30
                            content: t.taskName
                            wrappingWidth: 800
                            fill: Color.GRAY;
                        };
                    }
                    for (i in [0..Main.logger.todoTask.size()-1]) {
                        Text {
                            font: f30
                            content: Main.logger.todoTask.get(i).taskName
                            wrappingWidth: 700
                            fill: bind if (i==0) Color.RED else Color.BLACK
                        };
                    }
                    ];
    }
    def merci = Hyperlink {
                layoutX : 100;
                layoutY : 680;
                //wrappingWidth: 800
                visible:bind {Main.logger.todoTask.size() == 0};
                font: f30
                text: "Merci.\nVeuillez, s'il vous plait, remplir notre questionnaire."
                action: function() {
                       AppletStageExtension.showDocument("https://spreadsheets0.google.com/viewform?formkey=dEtiRTZtVmhTaGxQcFpDTnFIbWc2M1E6MQ");
                }
    }



    def btnGo = Button {
                layoutX : 400;
                layoutY : 670;
                font: f48
                text: "Suivant"
                visible:bind {Main.logger.todoTask.size() != 0};
                action: function() {
                    Main.animInfoTimer.stop();
                    Main.animInfoTimer.playFromStart();
                    Main.logger.currentTask = Main.logger.todoTask.get(0);
                    delete Main.logger.currentTask from Main.logger.todoTask;
                    this.visible = false;
                    Main.menu.visible = true;
                    Main.txtFooter.visible = true;
                }
            };
    override public function create(): Node {
        return Group {
                    content: [task,btnGo,titre,merci]
                }
     }
}
